<?php
/**
 * Created by PhpStorm.
 * User: tom_xia
 * Date: 2017/11/13
 * Time: 18:41
 * 加载公共配置文件 以及 注册加载器
 */
if(php_sapi_name() != "cli"){
    //$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';
//
    header('Access-Control-Allow-Origin:*');
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept,Cookie");
    header('Access-Control-Allow-Methods: GET, POST');
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 1728000');
    $requestMethod = $_SERVER['REQUEST_METHOD'];
    if( $requestMethod == "OPTIONS") die();
    header("Content-type:application/json");
}
//配置文件
//测试环境
//defined("PRODUCT_MODE") || define("PRODUCT_MODE","test");
//开发（预上线）环境
defined("PRODUCT_MODE") || define("PRODUCT_MODE","development");
//正式环境
//defined("PRODUCT_MODE") || define("PRODUCT_MODE","production");

if(PRODUCT_MODE == "development"){
    ini_set("display_errors","on");
    error_reporting ( E_ALL &~  E_NOTICE &~ E_WARNING);
    include_once __DIR__."/config/develop.php";
}elseif(PRODUCT_MODE == "production"){
//    error_reporting ( E_ALL &~ E_NOTICE  &~ E_WARNING);
//    ini_set("display_errors","on");
    include_once __DIR__."/config/product.php";
}elseif(PRODUCT_MODE == "test"){
    error_reporting ( E_ALL &~ E_NOTICE  &~ E_WARNING);
    ini_set("display_errors","on");
    include_once __DIR__."/config/config_test.php";
}
date_default_timezone_set("PRC");
//注册加载器
require_once __DIR__."/autoload.php";
